# 负责情景对话初始化
from fastapi import APIRouter, HTTPException

from core.situation import situations
from prompts.situation import *
from services.openai_service import json_generate

router = APIRouter()


@router.get(path="/situations", description="获取所有可用的大场景列表")
def get_situations():
    return {"situations": situations}


@router.get(path="/situation/{index}", description="获取该场景的具体信息")
async def create_detailed_situation(index: int):
    if index < 0 or index >= len(situations):
        raise HTTPException(status_code=404, detail="Situation not found.")

    situation = situations[index]
    messages = [
        {"role": "user", "content": prompt_for_detailed_situation},
        {
            "role": "user",
            "content": f"大场景为{situation.get("name_zh")}({situation.get("name_en")}), 描述为{situation.get("description")}",
        },
    ]
    detailed_situation: dict = json_generate(messages)
    return detailed_situation
